<?php
#基础函数
include_once('_path.php');

#通用函数
include_once(_CONST_LOCAL_INCLUDE_PATH."common.php");

#db
include_once(_CONST_LOCAL_INCLUDE_PATH."database.class.php");
$database = new Database($db_vars);

#权限
if (!is_logined()) {
header("Location:"._CONST_WEB_URL."login-company.html");
exit;
}

$action = trim($_GET['action']);

 if ($action == "edit.do") {

     #得到post的值
$company_name = trim($_REQUEST['company_name']);
	$quote['company_name'] = string_sql($company_name);
$company_legal = trim($_REQUEST['company_legal']);
	$quote['company_legal'] = string_sql($company_legal);
$company_region= trim($_REQUEST['company_region']);
	$quote['company_region'] = string_sql($company_region);
$company_capital = intval(trim($_REQUEST['company_capital']));
	$quote['company_capital'] = string_sql($company_capital);
$contact_username = trim($_REQUEST['contact_username']);
	$quote['contact_username'] = string_sql($contact_username);
$contact_tel = trim($_REQUEST['contact_tel']);
	$quote['contact_tel'] = string_sql($contact_tel);
$company_address = trim($_REQUEST['company_address']);
	$quote['company_address'] = string_sql($company_address);
$company_phone = trim($_REQUEST['company_phone']);
	$quote['company_phone'] = string_sql($company_phone);
$company_fax = trim($_REQUEST['company_fax']);
	$quote['company_fax'] = string_sql($company_fax);
$company_zipcode= trim($_REQUEST['company_zipcode']);
	$quote['company_zipcode'] = string_sql($company_zipcode);
$company_email = trim($_REQUEST['company_email']);
	$quote['company_email'] = string_sql($company_email);
$company_url = trim($_REQUEST['company_url']);
	$quote['company_url'] = string_sql($company_url);
$industry = trim($_REQUEST['industry']);
	$quote['industry'] = string_sql($industry);
$industry_detail = trim($_REQUEST['industry_detail']);
	$quote['industry_detail'] = string_sql($industry_detail);
$company_staff = intval(trim($_REQUEST['company_staff']));
	$quote['company_staff'] = string_sql($company_staff);
$turnover = intval(trim($_REQUEST['turnover']));
	$quote['turnover'] = string_sql($turnover);
$businesstime = intval(trim($_REQUEST['businesstime']));
	$quote['businesstime'] = string_sql($businesstime);
$demand = trim($_REQUEST['demand']);
	$quote['demand'] = string_sql($demand);
$services = trim($_REQUEST['services']);
	$quote['services'] = string_sql($services);

	verify_field("company_name", "企业名称", "empty");
        verify_field("contact_username", "联系人", "empty");
        verify_field("company_capital", "注册资本", "number_only");
        verify_field("contact_tel", "联系电话", "empty");
        verify_field("company_email", "企业电子邮箱", "email");
        verify_field("company_staff", "企业员工人数", "number_only");
        verify_field("turnover", "年营业额", "number_only");
        verify_field("businesstime", "营业时间", "number_only");

	if (!count($error_strs)) {
		$sql = "UPDATE customers SET ".
                "company_name = ".$quote['company_name'].", company_legal = ".$quote['company_legal'].", company_region = ".$quote['company_region'].", company_capital = ".$quote['company_capital'].", contact_username = ".$quote['contact_username'].
                ", contact_tel = ".$quote['contact_tel'].", company_address = ".$quote['company_address'].", company_phone = ".$quote['company_phone'].", company_fax = ".$quote['company_fax'].
                ", company_zipcode = ".$quote['company_zipcode'].", company_email = ".$quote['company_email'].", company_url = ".$quote['company_url'].", industry = ".$quote['industry'].
                ", industry_detail = ".$quote['industry_detail'].", company_staff = ".$quote['company_staff'].", turnover = ".$quote['turnover'].", businesstime = ".$quote['businesstime'].
                ", demand = ".$quote['demand'].", services = ".$quote['services'].
                " WHERE id = ".$_SESSION['user_id'].";";
                $rs = $database->execute($sql);
                $action = "";
	} else {
		$action = "edit.view";
	}
 }
$rs = $database->queryFirst("SELECT * FROM customers WHERE id=".$_SESSION['user_id'] );
?>
<!DOCTYPE HTML>
<html>
<head>
	<meta charset="UTF-8">
	<title>用户中心-Haiersi•GL-海尔斯管历健康服务网</title>
	<link href="../media/css/reset.css" rel="stylesheet" type="text/css"/>
	<link href="../media/css/base.css" rel="stylesheet" type="text/css"/>
	<script type="text/javascript" src="../media/js/jquery-1.4.2.min.js"></script>
           <script type="text/javascript" src="../media/js/jquery.validate.min.js"></script>
        <script type="text/javascript">
jQuery.noConflict();
jQuery(function($) {
  $('#form').validate({
  });
});
</script>
        <script type="text/javascript" src="../media/js/tiny_mce/tiny_mce.js"></script>

</head>
<body id="uc">
<div class="wrapper">
	<div class="header clearfix">
		<a  class="logo fl" href="../index.html"><h1>Hesgl</h1></a>
		<ul class="nav fr clearfix">
			<li class="cur"><a href="../index.html">首页</a></li>
			<li><a href="../about-us.html">关于我们</a></li>
			<li><a href="../services.html">我们的服务</a></li>
			<li><a href="../approach.html">我们的方法</a></li>
			<li><a href="../health.html">企业健康管理</a></li>
			<li><a href="../news.html">新闻</a></li>
			<li class="last"><a href="../contacts.html">联系我们</a></li>
		</ul>
	</div>

    <div class="content clearfix">
    	<div class="user-info">欢迎<em><?=$_SESSION['name']?></em> ［<a href="../logout.php">退出登录</a>］</div>
        <div class="main">
        		<div class="traininc-nav-list">
        		<ul>
        			<li class="selected"><a href="com-home.html">基本信息</a></li>
        			<li><a href="com-list.html">员工列表</a></li>
        		</ul>
        	</div>
        	<div class="box-con">
	        	<table class="table-view">
	        		<tr>
	        			<td class="title">您的编号</td>
	        			<td><?=$rs['id']?></td>
	        		</tr>
	        		<tr>
	        			<td class="title">您所属网点</td>
	        			<td><?=$rs['region']?></td>
	        		</tr>
	        	</table>
	        	<br />
	        	<h3>企业详细信息</h3>
                       <?php
                       if($action=="edit.view"){
                       ?>
                        <script language="javascript" type="text/javascript">
                        tinyMCE.init({
                        language : "zh-cn",
                        theme : "advanced",
                        mode: "exact",
                        elements : "services",
                        theme_advanced_toolbar_location : "top",
                        theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,"
                        + "justifyleft,justifycenter,justifyright,justifyfull,formatselect,"
                        + "bullist,numlist,outdent,indent",
                        theme_advanced_buttons2 : "link,unlink,anchor,image,separator,"
                        +"undo,redo,cleanup,code,separator,sub,sup,charmap",
                        theme_advanced_buttons3 : "",
                        height:"300px",
                        width:"600px"
                        });
                        </script>
                         <form action="com-home.php?action=edit.do" method="post" id="form" name="form">
        		<table class="table-view">
        			<tr>
        				<td class="title">企业注册号</td>
                                        <td><input type="text" name="company_no" size="30" value="<?= $rs['company_no'] ?>" readonly="true"> </td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">企业名称</td>
        				<td><input type="text" name="company_name" size="30" value="<?= $rs['company_name'] ?>" class="required"> <?= show_field_error('company_name') ?></td>
        				<td class="title">法人</td>
        				<td><input type="text" name="company_legal" size="30" value="<?= $rs['company_legal'] ?>"></td>
        			</tr>
        			<tr>
        				<td class="title">注册地</td>
        				<td><input type="text" name="company_region" size="30" value="<?= $rs['company_region'] ?>"></td>
        				<td class="title">注册资本</td>
        				<td><input type="text" name="company_capital" size="30" value="<?= $rs['company_capital'] ?>" class="required"> <?= show_field_error('company_capital') ?></td>
        			</tr>
        			<tr>
        				<td class="title">联系人</td>
        				<td><input type="text" name="contact_username" size="30" value="<?= $rs['contact_username'] ?>" class="required"> <?= show_field_error('contact_username') ?></td>
        				<td class="title">联系人电话</td>
        				<td><input type="text" name="contact_tel" size="30" value="<?= $rs['contact_tel'] ?>" class="required"> <?= show_field_error('contact_tel') ?></td>
        			</tr>
        			<tr>
        				<td class="title">企业地址</td>
        				<td><input type="text" name="company_address" size="30" value="<?= $rs['company_address'] ?>"></td>
        				<td class="title">邮编</td>
        				<td><input type="text" name="company_zipcode" size="30" value="<?= $rs['company_zipcode'] ?>"></td>
        			</tr>
        			<tr>
        				<td class="title">企业电话</td>
        				<td><input type="text" name="company_phone" size=30" value="<?= $rs['company_phone'] ?>"></td>
        				<td class="title">企业传真</td>
        				<td><input type="text" name="company_fax" size="30" value="<?= $rs['company_fax'] ?>"></td>
        			</tr>
        			<tr>
        				<td class="title">企业电子邮箱</td>
        				<td><input type="text" name="company_email" size="30" value="<?= $rs['company_email'] ?>" class="required email"> <?= show_field_error('company_email') ?></td>
        				<td class="title">企业官方网站</td>
        				<td><input type="text" name="company_url" size="30" value="<?= $rs['company_url'] ?>"></td>
        			</tr>
        			<tr>
        				<td class="title">行业</td>
        				<td><input type="text" name="industry" size="30" value="<?= $rs['industry'] ?>"></td>
        				<td class="title">具体</td>
        				<td><input type="text" name="industry_detail" size="30" value="<?= $rs['industry_detail'] ?>"></td>
        			</tr>
        			<tr>
        				<td class="title">企业员工人数</td>
        				<td><input type="text" name="company_staff" size="30" value="<?= $rs['company_staff'] ?>" class="required"> <?= show_field_error('company_staff') ?></td>
        				<td class="title">年营业额</td>
        				<td><input type="text" name="turnover" size="30" value="<?= $rs['turnover'] ?>" class="required"> <?= show_field_error('turnover') ?></td>
        			</tr>
        			<tr>
        				<td class="title">经营时间</td>
        				<td><input type="text" name="businesstime" size="30" value="<?= $rs['businesstime'] ?>" class="required"><?= show_field_error('businesstime') ?></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">服务需求</td>
        				<td><input type="text" name="demand" size="30" value="<?= $rs['demand'] ?>"></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">服务内容</td>
        				<td colspan="3"><textarea name="services" cols="30" rows="7"><?= $rs['services'] ?></textarea></td>
        			</tr>
        			<tr>
        				<td class="title"> </td>
        				<td><input type="submit" name="" value="提交" class="btnA" /></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        		</table>
                         </form>
                        <?php
                       }else{
                        ?>
                          <form action="com-home.php?action=edit.view" method="post" id="form" name="form">
        		<table class="table-view">
        			<tr>
        				<td class="title">企业注册号</td>
        				<td><?=$rs['company_no']?> </td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">企业名称</td>
        				<td><?=$rs['company_name']?></td>
        				<td class="title">法人</td>
        				<td><?=$rs['company_legal']?></td>
        			</tr>
        			<tr>
        				<td class="title">注册地</td>
        				<td><?=$rs['company_region']?></td>
        				<td class="title">注册资本</td>
        				<td><?=$rs['company_capital']?></td>
        			</tr>
        			<tr>
        				<td class="title">联系人</td>
        				<td><?=$rs['contact_username']?></td>
        				<td class="title">联系人电话</td>
        				<td><?=$rs['contact_tel']?></td>
        			</tr>
        			<tr>
        				<td class="title">企业地址</td>
        				<td><?=$rs['company_address']?></td>
        				<td class="title">邮编</td>
        				<td><?=$rs['company_zipcode']?></td>
        			</tr>
        			<tr>
        				<td class="title">企业电话</td>
        				<td><?=$rs['company_phone']?></td>
        				<td class="title">企业传真</td>
        				<td><?=$rs['company_fax']?></td>
        			</tr>
        			<tr>
        				<td class="title">企业电子邮箱</td>
        				<td><?=$rs['company_email']?></td>
        				<td class="title">企业官方网站</td>
        				<td><?=$rs['company_url']?></td>
        			</tr>
        			<tr>
        				<td class="title">行业</td>
        				<td><?=$rs['industry']?></td>
        				<td class="title">具体</td>
        				<td><?=$rs['industry_detail']?></td>
        			</tr>
        			<tr>
        				<td class="title">企业员工人数</td>
        				<td><?=$rs['company_staff']?></td>
        				<td class="title">年营业额</td>
        				<td><?=$rs['turnover']?></td>
        			</tr>
        			<tr>
        				<td class="title">经营时间</td>
        				<td><?=$rs['businesstime']?></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">服务需求</td>
        				<td><?=$rs['demand']?></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title">服务内容</td>
        				<td><?=$rs['services']?></td>
        				<td class="title"></td>
        				<td></td>
        			</tr>
        			<tr>
        				<td class="title"> </td>
        				<td colspan="3"><input type="submit" name="" value="修改" class="btnA" /></td>
        			</tr>
        		</table>
                          </form>
                       <?php
                       }
                        ?>
                        
        	</div>
        </div>

    </div>
	<div class="footer">
	    <p class="copyright">Copyright © 2011 Hesgl.com All Rights Reserved</p>
	</div>
</div>
</body>
</html>